Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

find-replace

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-replace

Find and either replace or remove items from an array

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

view on npm npm module downloads Build Status Dependency Status js-standard-style

find-replace

Find and either replace or remove items from an array.

Example

> findReplace = require('find-replace')

> findReplace([ 1, 2, 3], 2, 'two')
[ 1, 'two', 3 ]

> findReplace([ 1, 2, 3], 2, [ 'two', 'zwei' ])
[ 1, [ 'two', 'zwei' ], 3 ]

> findReplace([ 1, 2, 3], 2, 'two', 'zwei')
[ 1, 'two', 'zwei', 3 ]

> findReplace([ 1, 2, 3], 2) // no replacement, so remove
[ 1, 3 ]

findReplace(array, valueTest, [...replaceWith]) ⇒ array

Kind: Exported function

ParamTypeDescription
arrayarraythe input array
valueTestvalueTesta test-value query to match the value you're looking for
[...replaceWith]anyIf specified, found values will be replaced with these values, else removed.

© 2015-18 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

Keywords

FAQs

Package last updated on 05 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc